package com.wutong.teacher_server.config;

import org.springframework.context.annotation.Bean;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;


//@Configuration //声明该类为配置类
//@EnableSwagger2 //声明启动Swagger2
public class SwaggerConfig {

    ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("Swagger to Word")
                .description("a tool for converting swagger json to word")
                .license("Apache 2.0")
                .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
                .termsOfServiceUrl("")
                .version("0.0.1")
                .contact(new Contact("","", "15980292662@163.com"))
                .build();
    }

//        @Bean
//        public Docket createRestApi(){
//            return new Docket(DocumentationType.SWAGGER_2)
//                    .apiInfo(apiInfo())
//                    .select()
//                    //为当前包下controller生成API文档
//                    //                .apis(RequestHandlerSelectors.basePackage("com.troila"))
//                    //为有@Api注解的Controller生成API文档
//                    //                .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
//                    //为有@ApiOperation注解的方法生成API文档
//                    //                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
//                    //为任何接口生成API文档
//                    .apis(RequestHandlerSelectors.any())
//                    .paths(PathSelectors.any())
//                    .build();
//            //添加登录认证
//                    /*.securitySchemes(securitySchemes())
//                    .securityContexts(securityContexts());*/
//        }

    //    @Bean
    //    public Docket customImplementation(){
    //        return new Docket(DocumentationType.SWAGGER_2)
    //                .select()
    //                    .apis(RequestHandlerSelectors.basePackage("com.youwe.controller"))
    //                    .build()
    //                .directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class)
    //                .directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class)
    //                .apiInfo(apiInfo());
    //    }

    @Bean
    public Docket customDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.wutong.teacher_server.controller"))
                .build();
    }

}
